<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateItemTable extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $item = $this->table('item', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);

        $item->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 255, 'comment' => '项目名称'])
            ->addColumn('description', 'text', ['null' => true, 'comment' => '项目描述'])
            ->addColumn('is_del', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '是否删除,1：删除;0:不删除'])
            ->addColumn('last_update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('is_change','integer', ['signed' => false, 'default' => 0, 'limit' => 1, 'comment' => '权限状态'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('item');
    }
}
